package com.fingersoft.feature.deviceverify

import android.content.Context
import com.fingersoft.business.deviceverify.ChallengeResponse
import com.fingersoft.business.deviceverify.IDeviceVerifyContext
import com.fingersoft.business.deviceverify.VerifyDeviceResponse
import com.fingersoft.im.api.UserAgent
import com.fingersoft.im.utils.AppUtils
import com.fingersoft.im.utils.JSONUtils
import java.lang.ref.WeakReference

/**
 * @author：jooper  Email：jooperge@163.com
 * 描述：
 * 修改历史:
 * <p>
 * 创建于： 1/20/21
 */
open class SealDeviceVerifyContext : IDeviceVerifyContext {
    override fun empInfo(contextReference: WeakReference<Context?>): String {
        return JSONUtils.toJsonString(UserAgent(contextReference.get(), AppUtils.getTokenInfo().userToken, AppUtils.getTokenInfo().did))
    }

    override fun showApiSucceedErrorToast(response: ChallengeResponse): Boolean {
        return AppUtils.showApiSucceedErrorToast(response)
    }

    override fun showApiSucceedErrorToast(response: VerifyDeviceResponse): Boolean {
        return AppUtils.showApiSucceedErrorToast(response)
    }
}
